<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

    class Company_finance_info_model extends MY_Model
    {
        public function __construct() 
        {
            parent::__construct();
            $this->tbl_name = 'finance_infos';
        }
        
        function getStockTable($start = false, $limit = FALSE)
        {
            if( !$start )
            {
                $start = 0;
            }
            
            if( !$limit )
            {
                $limit = 20;
            }
            
            $sql = "
                    SELECT `finance_infos`.*
                    FROM `finance_infos`
                    WHERE `companies_id` 
                    IN (SELECT `id` 
                    FROM `companies`
                    WHERE `active` = 1)
                    GROUP BY `companies_id`
                    LIMIT $start, $limit
                ";
            
            $query = $this->db->query($sql);
            
            return $query->result_array();
        }   
    }
?>
